import 'package:boss/models/store_area.dart';
import 'package:boss/models/store_table.dart';
import 'package:flutter/material.dart';

class TableDetailProvider extends ChangeNotifier {
  StoreArea storeArea;
  StoreTable storeTable = StoreTable.fromJson({});
  bool get isUpdate {
    return storeTable.tableId != null;
  }

  TableDetailProvider({StoreArea storeArea, StoreTable storeTable}) {
    this.storeArea = storeArea;

    if (storeArea != null && storeTable == null) {
      storeTable = StoreTable.fromJson({});
      storeTable.areaId = storeArea.areaId;
      storeTable.areaName = storeArea.areaName;
    }

    if (storeTable != null) {
      this.storeTable = storeTable;
    }
  }

  setStoreArea(StoreArea storeArea) {
    this.storeArea = storeArea;

    storeTable.areaId = storeArea.areaId;
    storeTable.areaName = storeArea.areaName;

    notifyListeners();
  }

  setStoreTableName(String tableName) {
    storeTable.tableName = tableName;
    notifyListeners();
  }

  setStoreTableSeatNumber(int number) {
    storeTable.maxPerson = number;
    notifyListeners();
  }

}
